<title><?=$this->translate('edit_property_details')?></title>
<h1><?=$this->translate('edit_property_details')?></h1>
<style>
    input,textarea{
        width: 90%;
    }
    #propertyType-label{
        margin-top: 3%;
    }    
    #depositeValue,#prerentValue{
        margin-top: -12%;
        margin-left: 35%;
    }
    [required]{
        /*color:red;*/
        box-shadow: red;
    }
</style>
<script>
    $(function() {
        $("#addesc-label").remove();
        /**
         * vacant-date
         */
        $("#vac-date-label").remove();
        $("#vac-date-element").hide();
        $("#vac-date").datepicker({dateFormat: 'yy-mm-dd'});
        $("input[type=radio][name=vacant]").click(function() {
            if ($(this).is(':checked')) {
                if ($(this).val() == 2) {
                    $("#vac-date-element").show();
                } else {
                    $("#vac-date-element").hide();
                }
            }
        });
        if ($("input[type=radio][name=vacant]").is(':checked')) {
            if ($("#vacant-2").attr('checked') == "checked") {
                $("#vac-date-element").show();
            } else {
                $("#vac-date-element").hide();
            }
        }

        /**
         * pets-data
         */
        $("#pets-data-label").remove();
        $("#pets-data-element").hide();
        $("input[type=radio][name=pets]").click(function() {
            if ($(this).is(':checked')) {
                if ($(this).val() == 0) {
                    $("#pets-data-element").show();
                } else {
                    $("#pets-data-element").hide();
                }
            }
        });
        if ($("input[type=radio][name=pets]").is(':checked')) {
            if ($("#pets-0").attr('checked') == "checked") {
                $("#pets-data-element").show();
            } else {
                $("#pets-data-element").hide();
            }
        }


        /**
         * area append by meter square
         */
        $("#area-element").append(' m<sup>2</sup>');
//        $('#depositeSelect').append($('#depositeValue'));

        /**
         * Check for submit
         */

        $("input[name='submit']").click(function() {
            var isError = true;
            var firstThis;
            var index = 0;
            var errorMessage = "Please Enter Value...!!!";
            if ($("#adTitle").val().length == 0) {
                index++;
                firstThis = $("#adTitle");
                errorMessage = <?=$this->translate('enter_headline');?>;
                isError = false;
            } else if ($("#adDesc").val().length == 0) {
                index++;
                firstThis = $("#adDesc");
                errorMessage = <?=$this->translate('enter_description')?>;
                isError = false;
            }
            if (index == 0) {
                $("input[type='text']").each(function() {
                    var required = $(this).attr('req');
                    var val = $(this).val();
                    if (required === "req") {
                        if (val.length === 0) {
                            index++;
                            if (index == 1) {
                                firstThis = $(this);
                                errorMessage = $(this).attr('errMsg');
                                isError = false;
                            }
                        }
                    }
                });
            }
            if (index > 0) {
                alert("Please enter value");
                $(firstThis).focus();
            }
            return isError;
        });



    });
</script>
<div id="view-content">
    <div class="row-fluid">
        <div class="span6 well">
            <?= $this->form ?>
        </div>
        <?php
        if (sizeof($this->photos) > 0) {
            ?>
            <div class="span6 well">
                <table class="table">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Image</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $index = 1;
                        foreach ($this->photos as $p) :
                            $current = $index - 1;
                            ?>
                            <tr>
                                <td><?= $index ?></td>
                                <td><img src="http://<?= $_SERVER['SERVER_NAME'] ?>/uploads/<?= $p; ?>" width="125" height="125" /></td>
                                <td>
                                    <a class="btn btn-danger" href="<?= $this->url(array("id" => $this->proId . "_" . $current), 'delete-image'); ?>"><i class="icon-white icon-trash"></i></a>
                                </td>
                            </tr>
                            <?php
                            $index++;
                        endforeach;
                        ?>
                    </tbody>
                </table>

            </div>                                    
        <?php }
        ?>
    </div>
</div>